﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Jn698._45GWTool.Convers
{
    internal class StringToStopBitConver : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string str = "1";
            switch (value)
            {
                case StopBits.OnePointFive: 
                    str = "1.5"; 
                    break;
                case StopBits.Two:
                    str = "2";
                    break;
                case StopBits.One:
                default:
                    str = "1";
                    break;
            }
            return str;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value.Equals("1.5"))
            {
                return StopBits.OnePointFive;
            }
            else if (value.Equals("2"))
            {
                return StopBits.Two;
            }
            else
            {
                return StopBits.One;
            }
        }
    }
}
